//
//  BaseTVC.h
//  EPTool
//
//  Created by guoshiqing on 2018/4/25.
//  Copyright © 2018年 云数动能科技. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "ToastView.h"
#import "Macro.h"
#import "BaseViewModel.h"
#import "PlaceholderView.h"
#import "EMJRefreshHeader.h"
#import "EMJRefreshFooter.h"
#import "MJRefresh.h"
#import <UMCAnalytics/UMAnalytics/MobClick.h>

NS_ASSUME_NONNULL_BEGIN
@interface BaseTVC : UITableViewController

///////////// 属性 ///////

// 占位图
@property (nonatomic, strong) PlaceholderView *placeholderView;

// 自定义点击导航栏返回按钮事件
@property (nonatomic, copy) void (^leftNavButtonBlock )(void);
// 自定义点击导航栏右边按钮事件
@property (nonatomic, copy) void (^rightNavButtonBlock )(void);
@property (nonatomic, copy) void (^rightNavButtonListBlock )(NSInteger tag);
// 自定义导航栏左边返回按钮
@property (nonatomic, strong) UIButton *leftNavButton;
// 统一管理UIViewController的通知
@property (nonatomic, strong) NSMutableArray *observerList;
/** 1表示拉取新数据 2表示拉取历史数据 0表示拉取最新*/
@property (nonatomic, assign) FreshDirectionType getType;

//////////////UITableView接口函数//////////////
@property (nonatomic, strong, null_resettable) NSMutableArray *textList;
@property (nonatomic, strong) NSMutableArray *detailTextList;

#pragma mark - 返回按钮点击事件
- (void)btnBackClick:(id)sender;

// 接口ViewModel
@property (nonatomic, strong) BaseViewModel *baseVM;
#pragma mark - 接口调用返回结果处理
- (void)handelRequestData:(BaseJSONEntity *)returnValue;
- (void)createViewModel;

#pragma mark - 隐藏导航栏左边返回按钮
- (void)hideBackButton;
#pragma mark - 导航栏左边按钮
// 默认返回按钮
- (void)createBackButton;
- (void)createNavLeftBtnWithImageName:(NSString *)imageName;
#pragma mark - 导航栏右边'纯文字'按钮
// 导航栏右边按钮
- (void)createNavBarRightButtonWithName:(NSString *)titleName;
- (void)createNavBarRightButtonWithName:(NSString *)titleName withColor:(UIColor *)color;
- (void)createNavBarRightButtonWithImageName:(NSString *)imageName;

- (void)createNavBarRightButtonWithNameList:(NSArray *)titleNameList;
- (void)createNavBarRightButtonWithImageNameList:(NSArray *)imageNameList;

- (void)rightBarButtonWithStyle:(BOOL)isEnable;

#pragma mark - 弹出提示信息框
- (void)showAlertWithMessage:(NSString *)message;
- (void)showAlertWithTitle:(NSString *)title;
- (void)showAlertWithMessage:(NSString *)message handler:(void (^ __nullable)(UIAlertAction *action))handler;
- (void)showAlertWithTitle:(NSString *)title handler:(void (^ __nullable)(UIAlertAction *action))handler;
- (void)showAlertWithMessage:(NSString *)message cancel:(void (^ __nullable)(UIAlertAction *action))cancelHandler sure:(void (^ __nullable)(UIAlertAction *action))sureHandler;
- (void)showAlertWithTitle:(NSString *)title cancel:(void (^ __nullable)(UIAlertAction *action))cancelHandler sure:(void (^ __nullable)(UIAlertAction *action))sureHandler;
- (void)showAlertWithMessage:(NSString *)message title:(NSString *)title cancel:(void (^ __nullable)(UIAlertAction *action))cancelHandler sure:(void (^ __nullable)(UIAlertAction *action))sureHandler;
- (void)showAlertWithMessage:(NSString *)message title:(NSString *)title cancelStr:(NSString *)cancelStr sureStr:(NSString *)sureStr cancel:(void (^ __nullable)(UIAlertAction *action))cancelHandler sure:(void (^ __nullable)(UIAlertAction *action))sureHandler;
- (void)showAlertForInputPwdSuccess:(void (^)(NSString *password))success failure:(void (^)(void))failure;
- (void)showAlertForInputWithTitle:(NSString *)title Message:(NSString *)message andMaxNum:(NSInteger)maxNum Success:(void (^)(NSString *txfText))success failure:(void (^)(void))failure;
- (void)showAlertWithItemNameList:(NSArray <NSString *> *)nameList withBlock:(void (^ __nullable)(NSUInteger index, NSString *itemName))block;
- (void)showAlertWithItemNameList:(NSArray <NSString *> *)nameList withColor:(NSArray <UIColor *> *)colorList withBlock:(void (^ __nullable)(NSUInteger index, NSString *itemName))block;

#pragma mark - 弹出黑色信息框
- (void)showProcessingHud_Modal:(NSString *)msg;    //不允许整个屏幕的点击操作
- (void)hideProcessingHud_Modal;

- (void)showProcessingHud_Free:(NSString *)msg;     //允许所有操作
- (void)showProcessingHud:(NSString *)msg;          //不允许当前viewcontroller.View操作
- (void)hideProcessingHud;



- (void)changeTableViewHeight; // 根据站位图调整tableView的高度

#pragma mark - other
// 销毁自己
- (void)destroy;
// 退出当前页面
- (void)dismissVC;

#pragma mark - 控制器操作函数
// 跳转到某个控制器，参数为控制器名字
- (void)popToVCWithVCName:(NSString *)vcName;

// 获取最顶层的控制器
- (UIViewController *)topViewController;

// 根据名字找返回这个控制器
- (UIViewController *)returnVCWithVCName:(NSString *)vcName;


#pragma mark - TableViewController特殊需要，页面刷新促发
- (void)refreshAction;

#pragma mark - EMJRefresh
- (void)setMJRefreshSetting;
#pragma mark - 下拉加载最新
- (void)loadNewData;
#pragma mark - 上拉加载更多(历史)
- (void)loadHistroyData;
#pragma mark - 停止加载最新
- (void)endNewRefresh;
#pragma mark - 停止加载更多(历史)
- (void)endHistroyRefresh;


#pragma mark - 占位图
// 网络不可达占位图
- (void)showNetUnreachableImageName:(NSString *)name andBlock:(OperateBtnBlock)block;
// 网络请求失败占位图
- (void)showNetFailureImageName:(NSString *)name andBlock:(OperateBtnBlock)block;
// 暂无数据占位图
- (void)showNoDataImageName:(NSString *)name andMessage:(nullable NSString *)message;
// 暂无数据占位图但，但是有发布按钮
- (void)showNoDataImageName:(NSString *)name andMessage:(nullable NSString *)message withSignBtn:(nullable NSString *)btn andBlock:(OperateBtnBlock)block;

@end
NS_ASSUME_NONNULL_END
